package com.liang.auth.infra.basic.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liang.auth.infra.basic.entity.AuthUser;
import com.liang.auth.infra.basic.mapper.AuthUserMapper;
import com.liang.auth.infra.basic.service.AuthUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

/**
 * @author 29018
 * @description 针对表【auth_user】的数据库操作Service实现
 * @createDate 2024-10-22 14:13:21
 */
@Slf4j
@Service
public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, AuthUser> implements AuthUserService {

    @Override
    public Integer countByOpenId(String openId) {
        return lambdaQuery().eq(AuthUser::getUsername, openId).count();
    }

    @Override
    public AuthUser getUserInfo(AuthUser authUser) {
        return lambdaQuery().eq(AuthUser::getUsername, authUser.getUsername()).one();
    }

    @Override
    public List<AuthUser> getByUsernames(List<String> usernameList) {
        return lambdaQuery()
                .in(AuthUser::getUsername, usernameList)
                .list();
    }
}